﻿Imports DTO
Imports System.Data.OleDb

Public Class ChiTietPhieuNhapSachDAO

    Public Shared Function Them(ByVal chitietphieunhapdto As BangChiTietPhieuNhapSachDTO) As Integer
        Dim cnn As OleDbConnection = DataProvider.ConnectDB()
        Dim sql As String = "insert into CHITIETPHIEUNHAPSACH(MaSach,MaPhieuNhap,SoLuongNhap)values(?,?,?)"
        Dim cmd As OleDbCommand = New OleDbCommand(sql, cnn)
        cmd.Parameters.Add("@MaSach", OleDbType.Integer)
        cmd.Parameters.Add("@MaPhieuNhap", OleDbType.Integer)
        cmd.Parameters.Add("@SoLuongNhap", OleDbType.Integer)

        cmd.Parameters("@MaSach").Value = chitietphieunhapdto.MaSach
        cmd.Parameters("@MaPhieuNhap").Value = chitietphieunhapdto.MaPhieuNhap
        cmd.Parameters("@SoLuongNhap").Value = chitietphieunhapdto.SoLuongNhap

        cmd.ExecuteNonQuery()
        cmd.CommandText = "select @@IDENTITY"
        Dim i As Integer = cmd.ExecuteScalar()
        cnn.Close()
        Return i
    End Function

End Class
